<?php
/**
 * Controller_Admin_Active
 *
 * Класс Controller_Admin_Active отвечает за обработку информации об активах 
 *
 * @author Mike
 */
class Controller_Admin_Active extends Controller_Admin {

	/**
	 * Выбор действия по URL
	 *
	 */
	public function action() {
		if(!User_Seance::isAdmin()) throw new Exception('', 403);
		switch ($this->arrRequest[2]) {
			case '':
				$this->actionActivesList();
				break;
			default: throw new Exception('', 404);
		}
	}

	/**
	 * Выводит список товаров в активе
	 *
	 */
	public function actionActivesList() {
		$objProduct = new Product();
		$arrProducts = $objProduct->find('all', array(
				'select' => '`product`.*, `size`.`size_name`, `product_active`.`count`', 
				'joins' => 'INNER JOIN `product_active` USING(`ID_product`) INNER JOIN `size` USING(`ID_size`)',
				'order' => '`product`.`product_name`',
				'conditions' => '`product_active`.`count` > 0'
		));

		$this->title = $this->pageHead = 'Актив товаров';
		
		$this->showHeader();
			View_Product::showAdminACtiveList($arrProducts);
		$this->showFooter();
	}
}